package hacker_rank._101hack_mar14;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Stack;

public class HexagonalGrid {

	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int T = Integer.parseInt(br.readLine());

		for (int t = 0; t < T; t++) {
			int N = Integer.parseInt(br.readLine());
			int[][] grid = new int[2][N];

			String str = br.readLine();

			for (int i = 0; i < str.length(); i++) {
				grid[0][i] = str.charAt(i) - '0';
			}

			str = br.readLine();
			for (int i = 0; i < str.length(); i++) {
				grid[1][i] = str.charAt(i) - '0';
			}

			solve(grid, N);

		}

	}

	private static void solve(int[][] grid, int N) {
		int nBlack = 0;

		boolean[][] vis = new boolean[2][N];

		for (boolean[] v : vis)
			Arrays.fill(v, false);

		for (int i = 0; i < 2; i++) {
			for (int j = 0; j < N; j++) {
				if (grid[i][j] == 1) {
					nBlack++;
					vis[i][j] = true;
				}
			}
		}

		int cc = 2;
		for (int i = 0; i < 2; i++) {
			for (int j = 0; j < N; j++) {
				if (!vis[i][j]) {
					doDFS(grid, vis, i, j, N, cc);
					cc++;

				}
			}
		}

		Map<Integer, Integer> mapCnt = new HashMap<Integer, Integer>();

		for (int i = 0; i < 2; i++) {
			for (int j = 0; j < N; j++) {
				int t = grid[i][j];
				if (t > 1) {
					Integer c = mapCnt.get(t);
					if (c == null)
						c = 0;
					mapCnt.put(t, c + 1);
				}
			}
		}

		for (Integer c : mapCnt.values())
			if ((c & 1) == 1) {
				System.out.println("NO");
				return;
			}

		System.out.println("YES");

	}

	private static void doDFS(int[][] grid, boolean[][] vis, int i, int j,
			int N, int cc) {
		Stack<Node> st = new Stack<Node>();

		st.push(new Node(i, j));

		while (!st.isEmpty()) {
			Node t = st.pop();
			if (vis[t.x][t.y] == true)
				continue;
			vis[t.x][t.y] = true;
			grid[t.x][t.y] = cc;
			if (t.x - 1 >= 0 && t.y - 1 >= 0 && vis[t.x - 1][t.y - 1] == false)
				st.push(new Node(t.x - 1, t.y - 1)); // left diag up
			if (t.x + 1 < 2 && t.y + 1 < N && vis[t.x + 1][t.y + 1] == false)
				st.push(new Node(t.x + 1, t.y + 1)); // right diag down
			if (t.x - 1 >= 0 && vis[t.x - 1][t.y] == false)
				st.push(new Node(t.x - 1, t.y)); // up
			if (t.x + 1 < 2 && vis[t.x + 1][t.y] == false)
				st.push(new Node(t.x + 1, t.y)); // down;
			if (t.x + 1 < 2 && t.y - 1 >= 0 && vis[t.x + 1][t.y - 1] == false)
				st.push(new Node(t.x + 1, t.y - 1)); // left diag down;
			if (t.x - 1 >= 0 && t.y + 1 < N && vis[t.x - 1][t.y + 1] == false)
				st.push(new Node(t.x - 1, t.y + 1));
			if (t.y + 1 < N && vis[t.x][t.y + 1] == false)
				st.push(new Node(t.x, t.y + 1));
			if (t.y - 1 >= 0 && vis[t.x][t.y - 1] == false)
				st.push(new Node(t.x, t.y - 1));

		}

	}

	public static class Node {
		public int x;
		public int y;

		public Node(int x, int y) {
			this.x = x;
			this.y = y;
		}

		@Override
		public boolean equals(Object obj) {
			if (obj instanceof Node == false) {
				return false;
			}
			Node t = (Node) obj;
			if (this.x == t.x && this.y == t.y)
				return true;
			else
				return false;
		}

		@Override
		public int hashCode() {
			return (this.x * 13 * 13) + (this.y * 13);
		}

	}

}
